<?php

/** libraries
 * http://docs.joomla.org/JToolBarHelper
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

class bgViewbg extends JView
{
	// Overwriting JView display method
	function display($tpl = null) 
	{
        $task = &JRequest::getVar('task');
        $model = $this->getModel();
        
        switch($task){           
            case 'icon':
                $this->setLayout('icon');
            break;
            case 'print':     
                //Get data from model
                $this->filter = &JRequest::getVar('jform');
                $this->rows = $model->getAllClubPrint($this->filter);
                $this->setLayout('print');
            break;
            case 'detail':
                $this->setLayout('detail');
               
                $this->list = &JRequest::getVar('jform');
                //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->rows = $model->load($id);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
                
            break;
            case 'town':
                $this->setLayout('town');
                
                $this->list = &JRequest::getVar('jform');
                //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->row = $model->loadTown($id);
                    $this->club_in_town = $model->loadClubInTown($this->row->TOWN_CODE);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            case 'contact':
                $this->setLayout('contact');
                $this->list = &JRequest::getVar('jform');
                 //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->row = $model->loadContact($id);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            case 'activitive':
                $this->setLayout('activitive');
                $this->list = &JRequest::getVar('jform');
                 //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->rows = $model->loadActivity($id);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            case 'detail_activitive':
                $this->setLayout('detail_activitive');
            break;
            case 'center':
                $this->setLayout('center');
                $this->list = &JRequest::getVar('jform');
                 //show
                 
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->result =$model->load($id);
                    $a=$this->result->OCBA_CLUB_DEPEND;
                    $this->rows = $model->loadCenter($a);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
                
               
            break;
            case 'boathouse':
                $this->setLayout('boathouse');
                $this->list = &JRequest::getVar('jform');
               
                
                 //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->tbdo= $model->loadTbdo();
                    $this->row = $model->loadDock($id);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            case 'count':
                $year = JRequest::getVar('year');
                $id = JRequest::getVar('id');
                $filter = array(
                    'year' => $year,
                    'month' => '04',
                    'ocba_code' => $id,
                );
                
                $this->setLayout('count_participant');
                $this->statistic = $model->loadUscl($filter);
                $this->pacm = $model->loadPacm();
                $this->actm = $model->loadActm();
                if($id){
                  
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            case 'other_info':
                $this->setLayout('other_info');
                $this->list = &JRequest::getVar('jform');
                $master = new bgData();
                    //get activity
                    $this->listacti = $master->getActivity();
                 //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->row = $model->loadOtherInfo($id);
                    $this->listdm = $master->getDMClassification();
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            case 'coach':
                $this->setLayout('coach');
                $this->list = &JRequest::getVar('jform');
                 //show
                $id = JRequest::getVar('id');
                $id = is_array($id) ? $id[0] : $id;
                if($id){
                    $this->row = $model->loadCoach($id);
                    $this->info_ocba = $model->loadInfoOcba($id);
                }
            break;
            
            default:
                //check button search
                $check = &JRequest::getVar('check');
                if($check == '1')
                {
                    $this->sr = '1';
                }
                else $this->sr = '0';
                $this->result = &$model->getOCBA();
                $this->pagination =& $this->get('Pagination');  
                $this->setLayout('default');
        }
        
		parent::display();
	}
}




